package org.macpro.alone.server.domain;

import java.util.List;

/**
 * 分页信息封装类
 * 
 * @author 王东
 * 
 */
public class PageDomain {
	private int firstResourt;
	private int sizeResourt = 10;
	private int totalResourtSize;
	/**
	 * 当前页数
	 */

	private int crrentPage;
	private int totalPage;
	public List<Object> resourtList;

	public PageDomain(int crrentPage_) {
		crrentPage = crrentPage_;
	}
	/**对当前页进行初始化
	 * @param pagenum
	 * @return
	 */
	public static String initCurrentPage(String pagenum){
		if(pagenum==null||pagenum.equals(""))pagenum="1";
		return pagenum;
	}
	public PageDomain(int crrentPage_, int listSize) {
		crrentPage = crrentPage_;
		sizeResourt = listSize;
	}

	/**
	 * @return 开始记录数
	 */
	public int getFirstResourt() {
		firstResourt = (crrentPage - 1) * sizeResourt;
		return firstResourt;
	}

	/**
	 * @return 每页记录数
	 */
	public int getSizeResourt() {
		return sizeResourt;
	}

	/**
	 * 设置当前页
	 * 
	 * @return
	 */
	public PageDomain setCrrentPage() {
		return this;
	}

	public int getCrrentPage() {
		return crrentPage;
	}

	/**
	 * @return 总页数
	 */
	public int getTotalPage() {
		totalPage = totalResourtSize / sizeResourt + 1;
		if(totalResourtSize%sizeResourt==0)totalPage=totalPage-1;
		return totalPage;
	}

	public void setTotalResourtSize(int totalResourtSize) {
		this.totalResourtSize = totalResourtSize;
	}

	public int getTotalResourtSize() {
		return totalResourtSize;
	}
}
